<template>
	<view class="major-item w750 fboxRow Ycenter">
		<view class="fboxCol flex1" @click="schoolClick(info.majorCategoryId || info.id)">
			<view class="title font-ell1 font28 fboxRow color-36363A">
				<view class="name">{{ info.name }}</view>
			</view>
			<view class="tags fboxRow">
				<template v-if="type == 'list'">
					<view class="tag font22 bg-F5F5FA color-9899A1">{{ info.level1Name }}</view>
					<view class="tag font22 bg-F5F5FA color-9899A1">{{ info.level2Name }}</view>
				</template>
				<template v-if="type == 'collect'">
					<view v-for="(sub, i) in info.tags" :key="i" class="tag font22 bg-F5F5FA color-9899A1">{{sub}}
					</view>
				</template>
			</view>
		</view>
		<view class="collect" v-if="type == 'collect'">
			<text v-if="!info.isCheck" @tap="onCollect(info, index, true)"
				class="bksCIcon bks-c-ziyuan16weishoucang color-C8C8CC font36" />
			<text v-else @tap="onCollect(info, index, false)"
				class="bksCIcon bks-c-ziyuan17shoucang color-F7C34A font36" />
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			info: {
				type: Object,
				default: {}
			},
			type: {
				type: String,
				default: 'list' // list || collect
			},
			index: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				someData: {}
			};
		},
		methods: {
			schoolClick(id) {
				this.$pageTo('/bks/index/major/detail/index', {
					id
				})
			},
			onCollect(info, index, status) {
				this.$emit('collect', {
					info,
					index,
					status
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	.major-item {
		padding: 30rpx;
		height: 160rpx;
		border-bottom: 1px solid #f0f0f5;
		overflow: hidden;
	}

	.collect {
		margin-left: 20rpx;
	}

	.title {
		height: 48rpx;
		line-height: 48rpx;
	}

	// .title .name {
	// 	white-space: nowrap;
	// 	text-overflow: ellipsis;
	// 	overflow: hidden;
	// }

	.tags {
		margin-top: 10rpx;
	}

	.tags .tag {
		margin-right: 12rpx;
		padding: 0 16rpx;
		height: 36rpx;
		line-height: 36rpx;
		border-radius: 3rpx;
	}

	.bg-F5F5FA {
		background-color: #F5F5FA;
	}
</style>